import './assets/main.css'

import {createApp} from 'vue'
import App from './App.vue'
import { createPinia } from 'pinia'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import router from "@/router/index.js";
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import '@/permission.js'
import allGlobalComponent from '@/components'
import { timeFormat } from '@/util'
import { permissionDirective } from '@/directives/permission'


const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
const app = createApp(App)
app.use(pinia)
app.use(ElementPlus)
app.use(allGlobalComponent)
app.use(router)
app.directive('permission', permissionDirective)//权限校验指令
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.config.globalProperties.$timeFormat = timeFormat

// 添加路由导航完成后隐藏加载动画
router.isReady().then(() => {
    // 确保应用完全加载后再隐藏加载动画
    if (window.loaderController) {
        window.loaderController.complete()
    }
})

app.mount('#app')
